﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AlmaDatabase;

namespace Alma.Models
{
    public class ShopModel
    {
        [HiddenInput]
        [ReadOnly(true)]
        public long ID { get; set; }

        [HiddenInput]
        [ReadOnly(true)]
        public long? ID_User { get; set; }
        
        [DataType(DataType.Text)]
        [HiddenInput]
        public string Name_User { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [DisplayName("Nom du magasin")]
        public string Name { get; set; }

        [DataType(DataType.EmailAddress)]
        [DisplayName("E-Mail")]
        public string Email { get; set; }

        [DataType(DataType.PhoneNumber)]
        [DisplayName("Telephone")]
        public string Phone { get; set; }

        [DataType(DataType.PhoneNumber)]
        [DisplayName("Fax")]
        public string Fax { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [DisplayName("Adresse")]
        public string Address { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [DisplayName("Code Postal")]
        public int? Zipcode { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [DisplayName("Ville")]
        public string Town { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [DisplayName("Pays")]
        public string Country { get; set; }

        [Required]
        [DataType(DataType.MultilineText)]
        [DisplayName("Description du magasin")]
        public string Description { get; set; }
        public List<ProductDetailsModel> Products { get; set; }
        public string reviewText { get; set; }
        public int? reviewScore { get; set; }
        public float score { get; set; }
        public List<ProductReviewModel> reviews { get; set; }

        public double LocationX { get; set; }
        public double LocationY { get; set; }

        public string ImgUrl { get; set; }

        public ShopModel(Shop shop)
        {
            ID = shop.ID;
            ID_User = shop.ID_User;
            Name = shop.Name;
            Email = shop.Email;
            Phone = shop.Phone;
            Fax = shop.Fax;
            Address = shop.Address;
            Zipcode = shop.Zipcode;
            Town = shop.Town;
            Country = shop.Country;
            Description = shop.Description;
            ImgUrl = shop.ImgUrl ?? "~/Content/images/unavailable.gif";

            LocationX = shop.LocationX;
            LocationY = shop.LocationY;
        }

        public ShopModel()
        {
            // TODO: Complete member initialization
        }
    }
}